package com.neuedu.io;

import java.io.*;

public class StreamDemo2 {
    public static void main(String[] args) {
        //0000 0000  1111 1111   0 - 255    0 - 65535
       File  file = new File("D:/a.txt");
       File file2 = new File("D:/b.txt");
       if(!file2.exists()) {
           try {
               file2.createNewFile();
           } catch (IOException e) {
               throw new RuntimeException(e);
           }
       }
        InputStream  in;
        OutputStream  os;

        try {
            in = new FileInputStream(file);
            os = new FileOutputStream(file2);
            byte []  bt = new byte[20];
            int length=0;
//            public class  Hello
            length = in.read(bt,10,6);
            os.write(bt);
            in.close();
            os.close();
            System.out.println(length);
            System.out.println(bt);
//            while( (length= in.read(bt))!=-1) {
//                os.write(bt);
//                System.out.println(length);
//            }

            in.close();
            os.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        catch (IOException e){

        }

    }
}
